//
// Created by wenyaxi on 24-11-14.
//
#include <common.h>

class Solution {
public:
    int minimumBoxes(vector<int> &apple, vector<int> &capacity) {
        int sum = 0;
        ranges::for_each(apple, [&sum](const int x)-> void { sum += x; });
        ranges::sort(capacity,greater<int>());
        int cnt = 0;
        int sum_t=0;
        for (auto x : capacity) {
            cnt++;
            sum_t += x;
            if (sum_t >= sum) {
                return cnt;
            }
        }
    }
};

int main(int argc, char *argv[]) {
    const auto s = new Solution();
    /*
    [1,3,2]
    [4,3,1,5,2]
    [5,5,5]
    [2,4,2,7]
    */
    vector<int> apple{1, 3, 2};
    vector<int> capacity{4, 3, 1, 5, 2};
    const int minimum_boxes = s->minimumBoxes(apple, capacity);
    cout << minimum_boxes << endl;
    return 0;
}
